package com.myself.module.authority.mq.producer.email;

import com.myself.module.authority.mq.message.email.SendEmailMessage;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

/**
 * @author ChenZhongXian
 * @version 1.0
 * @description
 * @date 2024/5/20 15:33
 */
@Slf4j
@Component
public class SendEmailProvider {

    @Resource
    private ApplicationContext applicationContext;

    /**
     * 推送邮件
     *
     * @param mail      接收邮箱
     * @param accountId 推送邮箱编号
     * @param nickName  发件人名称
     * @param title     标题
     * @param content   推送内容
     */
    public void sendEmailMessage(String mail, Long accountId, String nickName, String title, String content) {
        SendEmailMessage sendEmailMessage = new SendEmailMessage().setMail(mail)
                .setAccountId(accountId)
                .setNickname(nickName)
                .setTitle(title)
                .setContent(content);
        applicationContext.publishEvent(sendEmailMessage);

    }

}
